from domain.domain import Image
class ImageDAO():

    def getAll(self, session):
        list = session.query(Image)
        return list

    def getById(self, session, id):
        list = session.query(Image).filter(Image.id == id).one()
        return list

    def update(self, session, Image):
        # newCatalog=session.query(Catalog).filter(Catalog.id==catalog.id).one()
        # newCatalog=catalog
        # 更新fullname

        session.commit()
        return "success"

    def getByName(self, session, name):
        list = session.query(Image).filter(Image.name == name).all()
        return list

    def deleteById(self, session, id):
        list = session.query(Image).filter(Image.id == id).delete()
        return "success"

    def add(self,session,image):
        session.add(image)
        session.commit()
        return "success"
